#!/bin/bash

set -e


IMG="local/docker-in-deb:latest"


git clean -fdX

case $1 in
    "")
        echo "use ./build.sh image to build runtime image"
        echo "use ./build.sh \$PROJECT_NAME build deb package"
        exit 1;;
    image)
        docker build -t $IMG --rm=true --force-rm=true .;;
    *)
        if [ ! -d $1 ]; then
            echo "project: \"$1\" not found!";
            exit 2
        fi
        docker run --rm=true -v `pwd`/$1:/home/debra/deb $IMG ./pack.sh
esac

git clean -fdX
